package com.xiaoshou.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Outtime {
	public static String OutDateTime(String time) {
		SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = null;

		try {
			date = sim.parse(time);
		} catch (ParseException e) {
			e.printStackTrace();
		}

		long exce = ((new Date().getTime() - date.getTime()) / 1000);
		String show = "";
		if (exce > (60 * 60 * 24 * 3)) {
			show = "3天前";
		} else if (exce > (60 * 60 * 24 * 2)) {
			show = "2天前";
		} else if (exce > (60 * 60 * 24)) {
			show = "1天前";
		} else if (exce > (60 * 60 * 20)) {
			show = "20小时前";
		} else if (exce > (60 * 60 * 10)) {
			show = "10小时前";
		} else if (exce > (60 * 60 * 5)) {
			show = "5小时前";
		} else if (exce > (60 * 60 * 3)) {
			show = "3小时前";
		} else if (exce > (60 * 60)) {
			show = "1小时前";
		} else if (exce > (60 * 30)) {
			show = "30分钟前";
		} else if (exce > (60 * 10)) {
			show = "10分钟前";
		} else if (exce > (60 * 5)) {
			show = "5分钟前";
		} else if (exce > (60 * 3)) {
			show = "3分钟前";
		} else if (exce > 60) {
			show = "1分钟前";
		} else if (exce > 30) {
			show = "30秒前";
		} else if (exce > 10) {
			show = "10秒前";
		} else if (exce > 5) {
			show = "5秒前";
		} else {
			show = "刚刚";
		}
		return show;
	}
}
